﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using XingLucifer.IBase.Enums;

namespace XingLucifer.IBase
{
    /// <summary>
    /// 设备通信接口
    /// </summary>
    public interface IDevices
    {
        bool WriteSingle(object value, int address, int offset, int length, int count = 3);
        bool WriteClass<TClass>(TClass value, int address, int count = 3) where TClass : class;
        TValue? ReadSingle<TValue>(int address, int length, int count = 3);
        TClass? ReadClass<TClass>(int address, TClass obj = default, int count = 3) where TClass : class;
        bool Open();
        void Close();
        string Read();
        public Dictionary<string, string> CircuitTesterReceive();
        /// <summary>
        /// 组装线PLC
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        bool WriteStringAsUInt16(string addr, string values);
        /// <summary>
        /// 组装线PLC
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        bool WriteString(string addr, string values);
        /// <summary>
        /// 组装线PLC
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="addr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        bool Write<T>(string addr, T[] values);
        /// <summary>
        /// 组装线PLC
        /// </summary>
        /// <param name="addr"></param>
        /// <returns></returns>
        bool ReadAndReturnBit(string addr);
        /// <summary>
        /// 组装线PLC
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        List<UInt16> Read(string addr, int count);
        /// <summary>
        /// 组装线PLC
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        string ReadString(string addr, int count);

    }
}
